home *** CD-ROM | disk | FTP | other *** search
/ Freelog 22 / freelog 22.iso / Prog / Djgpp / DJDEV203.ZIP / include / dos.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-06-03  |  7.0 KB  |  275 lines

  1. /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
  2. /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
  3. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  4. #ifndef __dj_include_dos_h_
  5. #define __dj_include_dos_h_
  6.  
  7. #ifndef __dj_ENFORCE_ANSI_FREESTANDING
  8.  
  9. #ifndef __STRICT_ANSI__
  10.  
  11. #ifndef _POSIX_SOURCE
  12.  
  13. #include <pc.h>
  14.  
  15. extern int _8087;
  16.  
  17. int _detect_80387(void);
  18.  
  19. struct DWORDREGS {
  20.   unsigned long edi;
  21.   unsigned long esi;
  22.   unsigned long ebp;
  23.   unsigned long cflag;
  24.   unsigned long ebx;
  25.   unsigned long edx;
  26.   unsigned long ecx;
  27.   unsigned long eax;
  28.   unsigned short eflags;
  29. };
  30.  
  31. struct DWORDREGS_W {
  32.   unsigned long di;
  33.   unsigned long si;
  34.   unsigned long bp;
  35.   unsigned long cflag;
  36.   unsigned long bx;
  37.   unsigned long dx;
  38.   unsigned long cx;
  39.   unsigned long ax;
  40.   unsigned short flags;
  41. };
  42.  
  43. struct WORDREGS {
  44.   unsigned short di, _upper_di;
  45.   unsigned short si, _upper_si;
  46.   unsigned short bp, _upper_bp;
  47.   unsigned short cflag, _upper_cflag;
  48.   unsigned short bx, _upper_bx;
  49.   unsigned short dx, _upper_dx;
  50.   unsigned short cx, _upper_cx;
  51.   unsigned short ax, _upper_ax;
  52.   unsigned short flags;
  53. };
  54.  
  55. struct BYTEREGS {
  56.   unsigned short di, _upper_di;
  57.   unsigned short si, _upper_si;
  58.   unsigned short bp, _upper_bp;
  59.   unsigned long cflag;
  60.   unsigned char bl;
  61.   unsigned char bh;
  62.   unsigned short _upper_bx;
  63.   unsigned char dl;
  64.   unsigned char dh;
  65.   unsigned short _upper_dx;
  66.   unsigned char cl;
  67.   unsigned char ch;
  68.   unsigned short _upper_cx;
  69.   unsigned char al;
  70.   unsigned char ah;
  71.   unsigned short _upper_ax;
  72.   unsigned short flags;
  73. };
  74.  
  75. union REGS {        /* Compatible with DPMI structure, except cflag */
  76.   struct DWORDREGS d;
  77. #ifdef _NAIVE_DOS_REGS
  78.   struct WORDREGS x;
  79. #else
  80. #ifdef _BORLAND_DOS_REGS
  81.   struct DWORDREGS x;
  82. #else
  83.   struct DWORDREGS_W x;
  84. #endif
  85. #endif
  86.   struct WORDREGS w;
  87.   struct BYTEREGS h;
  88. };
  89.  
  90. struct SREGS {
  91.   unsigned short es;
  92.   unsigned short ds;
  93.   unsigned short fs;
  94.   unsigned short gs;
  95.   unsigned short cs;
  96.   unsigned short ss;
  97. };
  98.  
  99. struct ftime {
  100.   unsigned ft_tsec:5;    /* 0-29, double to get real seconds */
  101.   unsigned ft_min:6;    /* 0-59 */
  102.   unsigned ft_hour:5;    /* 0-23 */
  103.   unsigned ft_day:5;    /* 1-31 */
  104.   unsigned ft_month:4;    /* 1-12 */
  105.   unsigned ft_year:7;    /* since 1980 */
  106. };
  107.  
  108. struct date {
  109.   short da_year;
  110.   char  da_day;
  111.   char  da_mon;
  112. };
  113.  
  114. struct time {
  115.   unsigned char ti_min;
  116.   unsigned char ti_hour;
  117.   unsigned char ti_hund;
  118.   unsigned char ti_sec;
  119. };
  120.  
  121. struct dfree {
  122.   unsigned df_avail;
  123.   unsigned df_total;
  124.   unsigned df_bsec;
  125.   unsigned df_sclus;
  126. };
  127.  
  128. #ifdef __cplusplus
  129. extern "C" {
  130. #endif
  131.  
  132. extern unsigned short   _osmajor, _osminor;
  133. extern const    char  * _os_flavor;
  134. extern int        _doserrno;
  135.  
  136. unsigned short _get_dos_version(int);
  137.  
  138.  
  139. int int86(int ivec, union REGS *in, union REGS *out);
  140. int int86x(int ivec, union REGS *in, union REGS *out, struct SREGS *seg);
  141. int intdos(union REGS *in, union REGS *out);
  142. int intdosx(union REGS *in, union REGS *out, struct SREGS *seg);
  143. int bdos(int func, unsigned dx, unsigned al);
  144. int bdosptr(int func, void *dx, unsigned al);
  145.  
  146. #define bdosptr(a, b, c) bdos(a, (unsigned)(b), c)
  147. #define intdos(a, b) int86(0x21, a, b)
  148. #define intdosx(a, b, c) int86x(0x21, a, b, c)
  149.  
  150. int enable(void);
  151. int disable(void);
  152.  
  153. int getftime(int handle, struct ftime *ftimep);
  154. int setftime(int handle, struct ftime *ftimep);
  155.  
  156. int getcbrk(void);
  157. int setcbrk(int new_value);
  158.  
  159. void getdate(struct date *);
  160. void gettime(struct time *);
  161. void setdate(struct date *);
  162. void settime(struct time *);
  163.  
  164. void getdfree(unsigned char drive, struct dfree *ptr);
  165.  
  166. void delay(unsigned msec);
  167. /* int _get_default_drive(void);
  168. void _fixpath(const char *, char *); */
  169.  
  170.  
  171. /*
  172.  *  For compatibility with other DOS C compilers.
  173.  */
  174.  
  175. #define _A_NORMAL   0x00    /* Normal file - No read/write restrictions */
  176. #define _A_RDONLY   0x01    /* Read only file */
  177. #define _A_HIDDEN   0x02    /* Hidden file */
  178. #define _A_SYSTEM   0x04    /* System file */
  179. #define _A_VOLID    0x08    /* Volume ID file */
  180. #define _A_SUBDIR   0x10    /* Subdirectory */
  181. #define _A_ARCH     0x20    /* Archive file */
  182.  
  183. #define _enable   enable
  184. #define _disable  disable
  185.  
  186. struct _dosdate_t {
  187.   unsigned char  day;       /* 1-31 */
  188.   unsigned char  month;     /* 1-12 */
  189.   unsigned short year;      /* 1980-2099 */
  190.   unsigned char  dayofweek; /* 0-6, 0=Sunday */
  191. };
  192. #define dosdate_t _dosdate_t
  193.  
  194. struct _dostime_t {
  195.   unsigned char hour;     /* 0-23 */
  196.   unsigned char minute;   /* 0-59 */
  197.   unsigned char second;   /* 0-59 */
  198.   unsigned char hsecond;  /* 0-99 */
  199. };
  200. #define dostime_t _dostime_t
  201.  
  202. struct _find_t {
  203.   char reserved[21] __attribute__((packed));
  204.   unsigned char attrib __attribute__((packed));
  205.   unsigned short wr_time __attribute__((packed));
  206.   unsigned short wr_date __attribute__((packed));
  207.   unsigned long size __attribute__((packed));
  208.   char name[256] __attribute__((packed));
  209. };
  210. #define find_t _find_t
  211.  
  212. struct _diskfree_t {
  213.   unsigned short total_clusters;
  214.   unsigned short avail_clusters;
  215.   unsigned short sectors_per_cluster;
  216.   unsigned short bytes_per_sector;
  217. };
  218. #define diskfree_t _diskfree_t
  219.  
  220. struct _DOSERROR {
  221.   int  exterror;
  222.   #ifdef __cplusplus
  223.   char errclass;
  224.   #else
  225.   char class;
  226.   #endif
  227.   char action;
  228.   char locus;
  229. };
  230. #define DOSERROR _DOSERROR
  231.  
  232. unsigned int   _dos_creat(const char *_filename, unsigned int _attr, int *_handle);
  233. unsigned int   _dos_creatnew(const char *_filename, unsigned int _attr, int *_handle);
  234. unsigned int   _dos_open(const char *_filename, unsigned int _mode, int *_handle);
  235. unsigned int   _dos_write(int _handle, const void *_buffer, unsigned int _count, unsigned int *_result);
  236. unsigned int   _dos_read(int _handle, void *_buffer, unsigned int _count, unsigned int *_result);
  237. unsigned int   _dos_close(int _handle);
  238. unsigned int   _dos_commit(int _handle);
  239.  
  240. unsigned int   _dos_findfirst(const char *_name, unsigned int _attr, struct _find_t *_result);
  241. unsigned int   _dos_findnext(struct _find_t *_result);
  242.  
  243. void           _dos_getdate(struct _dosdate_t *_date);
  244. unsigned int   _dos_setdate(struct _dosdate_t *_date);
  245. void           _dos_gettime(struct _dostime_t *_time);
  246. unsigned int   _dos_settime(struct _dostime_t *_time);
  247.  
  248. unsigned int   _dos_getftime(int _handle, unsigned int *_p_date, unsigned int *_p_time);
  249. unsigned int   _dos_setftime(int _handle, unsigned int _date, unsigned int _time);
  250. unsigned int   _dos_getfileattr(const char *_filename, unsigned int *_p_attr);
  251. unsigned int   _dos_setfileattr(const char *_filename, unsigned int _attr);
  252.  
  253. void           _dos_getdrive(unsigned int *_p_drive);
  254. void           _dos_setdrive(unsigned int _drive, unsigned int *_p_drives);
  255. unsigned int   _dos_getdiskfree(unsigned int _drive, struct _diskfree_t *_diskspace);
  256.  
  257. int            _dosexterr(struct _DOSERROR *_p_error);
  258. #define dosexterr(_ep) _dosexterr(_ep)
  259.  
  260. #define int386(_i, _ir, _or)         int86(_i, _ir, _or)
  261. #define int386x(_i, _ir, _or, _sr)   int86x(_i, _ir, _or, _sr)
  262.  
  263. #ifdef __cplusplus
  264. }
  265. #endif
  266.  
  267. #endif /* !_POSIX_SOURCE */
  268. #endif /* !__STRICT_ANSI__ */
  269. #endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
  270.  
  271. #ifndef __dj_ENFORCE_FUNCTION_CALLS
  272. #endif /* !__dj_ENFORCE_FUNCTION_CALLS */
  273.  
  274. #endif /* !__dj_include_dos_h_ */
  275.